{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CRIM</th>\n",
       "      <th>ZN</th>\n",
       "      <th>INDUS</th>\n",
       "      <th>CHAS</th>\n",
       "      <th>NOX</th>\n",
       "      <th>RM</th>\n",
       "      <th>AGE</th>\n",
       "      <th>DIS</th>\n",
       "      <th>RAD</th>\n",
       "      <th>TAX</th>\n",
       "      <th>PTRATIO</th>\n",
       "      <th>B</th>\n",
       "      <th>LSTAT</th>\n",
       "      <th>MEDV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.00632</td>\n",
       "      <td>18</td>\n",
       "      <td>2.31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.538</td>\n",
       "      <td>6.575</td>\n",
       "      <td>65.2</td>\n",
       "      <td>4.0900</td>\n",
       "      <td>1</td>\n",
       "      <td>296</td>\n",
       "      <td>15</td>\n",
       "      <td>396.90</td>\n",
       "      <td>4.98</td>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.02731</td>\n",
       "      <td>0</td>\n",
       "      <td>7.07</td>\n",
       "      <td>0</td>\n",
       "      <td>0.469</td>\n",
       "      <td>6.421</td>\n",
       "      <td>78.9</td>\n",
       "      <td>4.9671</td>\n",
       "      <td>2</td>\n",
       "      <td>242</td>\n",
       "      <td>17</td>\n",
       "      <td>396.90</td>\n",
       "      <td>9.14</td>\n",
       "      <td>21.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.02729</td>\n",
       "      <td>0</td>\n",
       "      <td>7.07</td>\n",
       "      <td>0</td>\n",
       "      <td>0.469</td>\n",
       "      <td>7.185</td>\n",
       "      <td>61.1</td>\n",
       "      <td>4.9671</td>\n",
       "      <td>2</td>\n",
       "      <td>242</td>\n",
       "      <td>17</td>\n",
       "      <td>392.83</td>\n",
       "      <td>4.03</td>\n",
       "      <td>34.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.03237</td>\n",
       "      <td>0</td>\n",
       "      <td>2.18</td>\n",
       "      <td>0</td>\n",
       "      <td>0.458</td>\n",
       "      <td>6.998</td>\n",
       "      <td>45.8</td>\n",
       "      <td>6.0622</td>\n",
       "      <td>3</td>\n",
       "      <td>222</td>\n",
       "      <td>18</td>\n",
       "      <td>394.63</td>\n",
       "      <td>2.94</td>\n",
       "      <td>33.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.06905</td>\n",
       "      <td>0</td>\n",
       "      <td>2.18</td>\n",
       "      <td>0</td>\n",
       "      <td>0.458</td>\n",
       "      <td>7.147</td>\n",
       "      <td>54.2</td>\n",
       "      <td>6.0622</td>\n",
       "      <td>3</td>\n",
       "      <td>222</td>\n",
       "      <td>18</td>\n",
       "      <td>396.90</td>\n",
       "      <td>5.33</td>\n",
       "      <td>36.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      CRIM  ZN  INDUS  CHAS    NOX     RM   AGE     DIS  RAD  TAX  PTRATIO  \\\n",
       "0  0.00632  18   2.31     0  0.538  6.575  65.2  4.0900    1  296       15   \n",
       "1  0.02731   0   7.07     0  0.469  6.421  78.9  4.9671    2  242       17   \n",
       "2  0.02729   0   7.07     0  0.469  7.185  61.1  4.9671    2  242       17   \n",
       "3  0.03237   0   2.18     0  0.458  6.998  45.8  6.0622    3  222       18   \n",
       "4  0.06905   0   2.18     0  0.458  7.147  54.2  6.0622    3  222       18   \n",
       "\n",
       "        B  LSTAT  MEDV  \n",
       "0  396.90   4.98  24.0  \n",
       "1  396.90   9.14  21.6  \n",
       "2  392.83   4.03  34.7  \n",
       "3  394.63   2.94  33.4  \n",
       "4  396.90   5.33  36.2  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=pd.read_csv(r'C:\\Users\\Administrator\\Desktop\\boston_housing.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method DataFrame.info of          CRIM  ZN  INDUS  CHAS    NOX     RM    AGE     DIS  RAD  TAX  \\\n",
       "0     0.00632  18   2.31     0  0.538  6.575   65.2  4.0900    1  296   \n",
       "1     0.02731   0   7.07     0  0.469  6.421   78.9  4.9671    2  242   \n",
       "2     0.02729   0   7.07     0  0.469  7.185   61.1  4.9671    2  242   \n",
       "3     0.03237   0   2.18     0  0.458  6.998   45.8  6.0622    3  222   \n",
       "4     0.06905   0   2.18     0  0.458  7.147   54.2  6.0622    3  222   \n",
       "5     0.02985   0   2.18     0  0.458  6.430   58.7  6.0622    3  222   \n",
       "6     0.08829  12   7.87     0  0.524  6.012   66.6  5.5605    5  311   \n",
       "7     0.14455  12   7.87     0  0.524  6.172   96.1  5.9505    5  311   \n",
       "8     0.21124  12   7.87     0  0.524  5.631  100.0  6.0821    5  311   \n",
       "9     0.17004  12   7.87     0  0.524  6.004   85.9  6.5921    5  311   \n",
       "10    0.22489  12   7.87     0  0.524  6.377   94.3  6.3467    5  311   \n",
       "11    0.11747  12   7.87     0  0.524  6.009   82.9  6.2267    5  311   \n",
       "12    0.09378  12   7.87     0  0.524  5.889   39.0  5.4509    5  311   \n",
       "13    0.62976   0   8.14     0  0.538  5.949   61.8  4.7075    4  307   \n",
       "14    0.63796   0   8.14     0  0.538  6.096   84.5  4.4619    4  307   \n",
       "15    0.62739   0   8.14     0  0.538  5.834   56.5  4.4986    4  307   \n",
       "16    1.05393   0   8.14     0  0.538  5.935   29.3  4.4986    4  307   \n",
       "17    0.78420   0   8.14     0  0.538  5.990   81.7  4.2579    4  307   \n",
       "18    0.80271   0   8.14     0  0.538  5.456   36.6  3.7965    4  307   \n",
       "19    0.72580   0   8.14     0  0.538  5.727   69.5  3.7965    4  307   \n",
       "20    1.25179   0   8.14     0  0.538  5.570   98.1  3.7979    4  307   \n",
       "21    0.85204   0   8.14     0  0.538  5.965   89.2  4.0123    4  307   \n",
       "22    1.23247   0   8.14     0  0.538  6.142   91.7  3.9769    4  307   \n",
       "23    0.98843   0   8.14     0  0.538  5.813  100.0  4.0952    4  307   \n",
       "24    0.75026   0   8.14     0  0.538  5.924   94.1  4.3996    4  307   \n",
       "25    0.84054   0   8.14     0  0.538  5.599   85.7  4.4546    4  307   \n",
       "26    0.67191   0   8.14     0  0.538  5.813   90.3  4.6820    4  307   \n",
       "27    0.95577   0   8.14     0  0.538  6.047   88.8  4.4534    4  307   \n",
       "28    0.77299   0   8.14     0  0.538  6.495   94.4  4.4547    4  307   \n",
       "29    1.00245   0   8.14     0  0.538  6.674   87.3  4.2390    4  307   \n",
       "..        ...  ..    ...   ...    ...    ...    ...     ...  ...  ...   \n",
       "476   4.87141   0  18.10     0  0.614  6.484   93.6  2.3053   24  666   \n",
       "477  15.02340   0  18.10     0  0.614  5.304   97.3  2.1007   24  666   \n",
       "478  10.23300   0  18.10     0  0.614  6.185   96.7  2.1705   24  666   \n",
       "479  14.33370   0  18.10     0  0.614  6.229   88.0  1.9512   24  666   \n",
       "480   5.82401   0  18.10     0  0.532  6.242   64.7  3.4242   24  666   \n",
       "481   5.70818   0  18.10     0  0.532  6.750   74.9  3.3317   24  666   \n",
       "482   5.73116   0  18.10     0  0.532  7.061   77.0  3.4106   24  666   \n",
       "483   2.81838   0  18.10     0  0.532  5.762   40.3  4.0983   24  666   \n",
       "484   2.37857   0  18.10     0  0.583  5.871   41.9  3.7240   24  666   \n",
       "485   3.67367   0  18.10     0  0.583  6.312   51.9  3.9917   24  666   \n",
       "486   5.69175   0  18.10     0  0.583  6.114   79.8  3.5459   24  666   \n",
       "487   4.83567   0  18.10     0  0.583  5.905   53.2  3.1523   24  666   \n",
       "488   0.15086   0  27.74     0  0.609  5.454   92.7  1.8209    4  711   \n",
       "489   0.18337   0  27.74     0  0.609  5.414   98.3  1.7554    4  711   \n",
       "490   0.20746   0  27.74     0  0.609  5.093   98.0  1.8226    4  711   \n",
       "491   0.10574   0  27.74     0  0.609  5.983   98.8  1.8681    4  711   \n",
       "492   0.11132   0  27.74     0  0.609  5.983   83.5  2.1099    4  711   \n",
       "493   0.17331   0   9.69     0  0.585  5.707   54.0  2.3817    6  391   \n",
       "494   0.27957   0   9.69     0  0.585  5.926   42.6  2.3817    6  391   \n",
       "495   0.17899   0   9.69     0  0.585  5.670   28.8  2.7986    6  391   \n",
       "496   0.28960   0   9.69     0  0.585  5.390   72.9  2.7986    6  391   \n",
       "497   0.26838   0   9.69     0  0.585  5.794   70.6  2.8927    6  391   \n",
       "498   0.23912   0   9.69     0  0.585  6.019   65.3  2.4091    6  391   \n",
       "499   0.17783   0   9.69     0  0.585  5.569   73.5  2.3999    6  391   \n",
       "500   0.22438   0   9.69     0  0.585  6.027   79.7  2.4982    6  391   \n",
       "501   0.06263   0  11.93     0  0.573  6.593   69.1  2.4786    1  273   \n",
       "502   0.04527   0  11.93     0  0.573  6.120   76.7  2.2875    1  273   \n",
       "503   0.06076   0  11.93     0  0.573  6.976   91.0  2.1675    1  273   \n",
       "504   0.10959   0  11.93     0  0.573  6.794   89.3  2.3889    1  273   \n",
       "505   0.04741   0  11.93     0  0.573  6.030   80.8  2.5050    1  273   \n",
       "\n",
       "     PTRATIO       B  LSTAT  MEDV  \n",
       "0         15  396.90   4.98  24.0  \n",
       "1         17  396.90   9.14  21.6  \n",
       "2         17  392.83   4.03  34.7  \n",
       "3         18  394.63   2.94  33.4  \n",
       "4         18  396.90   5.33  36.2  \n",
       "5         18  394.12   5.21  28.7  \n",
       "6         15  395.60  12.43  22.9  \n",
       "7         15  396.90  19.15  27.1  \n",
       "8         15  386.63  29.93  16.5  \n",
       "9         15  386.71  17.10  18.9  \n",
       "10        15  392.52  20.45  15.0  \n",
       "11        15  396.90  13.27  18.9  \n",
       "12        15  390.50  15.71  21.7  \n",
       "13        21  396.90   8.26  20.4  \n",
       "14        21  380.02  10.26  18.2  \n",
       "15        21  395.62   8.47  19.9  \n",
       "16        21  386.85   6.58  23.1  \n",
       "17        21  386.75  14.67  17.5  \n",
       "18        21  288.99  11.69  20.2  \n",
       "19        21  390.95  11.28  18.2  \n",
       "20        21  376.57  21.02  13.6  \n",
       "21        21  392.53  13.83  19.6  \n",
       "22        21  396.90  18.72  15.2  \n",
       "23        21  394.54  19.88  14.5  \n",
       "24        21  394.33  16.30  15.6  \n",
       "25        21  303.42  16.51  13.9  \n",
       "26        21  376.88  14.81  16.6  \n",
       "27        21  306.38  17.28  14.8  \n",
       "28        21  387.94  12.80  18.4  \n",
       "29        21  380.23  11.98  21.0  \n",
       "..       ...     ...    ...   ...  \n",
       "476       20  396.21  18.68  16.7  \n",
       "477       20  349.48  24.91  12.0  \n",
       "478       20  379.70  18.03  14.6  \n",
       "479       20  383.32  13.11  21.4  \n",
       "480       20  396.90  10.74  23.0  \n",
       "481       20  393.07   7.74  23.7  \n",
       "482       20  395.28   7.01  25.0  \n",
       "483       20  392.92  10.42  21.8  \n",
       "484       20  370.73  13.34  20.6  \n",
       "485       20  388.62  10.58  21.2  \n",
       "486       20  392.68  14.98  19.1  \n",
       "487       20  388.22  11.45  20.6  \n",
       "488       20  395.09  18.06  15.2  \n",
       "489       20  344.05  23.97   7.0  \n",
       "490       20  318.43  29.68   8.1  \n",
       "491       20  390.11  18.07  13.6  \n",
       "492       20  396.90  13.35  20.1  \n",
       "493       19  396.90  12.01  21.8  \n",
       "494       19  396.90  13.59  24.5  \n",
       "495       19  393.29  17.60  23.1  \n",
       "496       19  396.90  21.14  19.7  \n",
       "497       19  396.90  14.10  18.3  \n",
       "498       19  396.90  12.92  21.2  \n",
       "499       19  395.77  15.10  17.5  \n",
       "500       19  396.90  14.33  16.8  \n",
       "501       21  391.99   9.67  22.4  \n",
       "502       21  396.90   9.08  20.6  \n",
       "503       21  396.90   5.64  23.9  \n",
       "504       21  393.45   6.48  22.0  \n",
       "505       21  396.90   7.88  11.9  \n",
       "\n",
       "[506 rows x 14 columns]>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#数据分离\n",
    "y=df['MEDV']\n",
    "x=df.drop('MEDV',axis=1)\n",
    "log_y=np.log1p(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "#离散型特征编码——独热码\n",
    "x['RAD'].astype('object')\n",
    "x_cat=x['RAD']\n",
    "x_cat=pd.get_dummies(x_cat,prefix='RAD')\n",
    "x=x.drop('RAD',axis=1)\n",
    "feat_names=x.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>RAD_1</th>\n",
       "      <th>RAD_2</th>\n",
       "      <th>RAD_3</th>\n",
       "      <th>RAD_4</th>\n",
       "      <th>RAD_5</th>\n",
       "      <th>RAD_6</th>\n",
       "      <th>RAD_7</th>\n",
       "      <th>RAD_8</th>\n",
       "      <th>RAD_24</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   RAD_1  RAD_2  RAD_3  RAD_4  RAD_5  RAD_6  RAD_7  RAD_8  RAD_24\n",
       "0      1      0      0      0      0      0      0      0       0\n",
       "1      0      1      0      0      0      0      0      0       0\n",
       "2      0      1      0      0      0      0      0      0       0\n",
       "3      0      0      1      0      0      0      0      0       0\n",
       "4      0      0      1      0      0      0      0      0       0"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_cat.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import MinMaxScaler\n",
    "#初始化特征值和目标值的最大最小器\n",
    "ss_x=MinMaxScaler()\n",
    "ss_y=MinMaxScaler()\n",
    "ss_log_y=MinMaxScaler()\n",
    "\n",
    "x=ss_x.fit_transform(x)\n",
    "y = ss_y.fit_transform(y.reshape(-1, 1))\n",
    "log_y = ss_y.fit_transform(log_y.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "fe_data=pd.DataFrame(data=x,columns=feat_names,index=df.index)\n",
    "fe_data=pd.concat([fe_data,x_cat],axis=1,ignore_index=False)\n",
    "\n",
    "fe_data['MEDV']=y\n",
    "fe_data['log_MEDV']=log_y\n",
    "\n",
    "fe_data.to_csv('FE_boston-housing.csv',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CRIM</th>\n",
       "      <th>ZN</th>\n",
       "      <th>INDUS</th>\n",
       "      <th>CHAS</th>\n",
       "      <th>NOX</th>\n",
       "      <th>RM</th>\n",
       "      <th>AGE</th>\n",
       "      <th>DIS</th>\n",
       "      <th>TAX</th>\n",
       "      <th>PTRATIO</th>\n",
       "      <th>...</th>\n",
       "      <th>RAD_2</th>\n",
       "      <th>RAD_3</th>\n",
       "      <th>RAD_4</th>\n",
       "      <th>RAD_5</th>\n",
       "      <th>RAD_6</th>\n",
       "      <th>RAD_7</th>\n",
       "      <th>RAD_8</th>\n",
       "      <th>RAD_24</th>\n",
       "      <th>MEDV</th>\n",
       "      <th>log_MEDV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.18</td>\n",
       "      <td>0.067815</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.314815</td>\n",
       "      <td>0.577505</td>\n",
       "      <td>0.641607</td>\n",
       "      <td>0.269203</td>\n",
       "      <td>0.208015</td>\n",
       "      <td>0.3</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>3.218876</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000236</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.242302</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.172840</td>\n",
       "      <td>0.547998</td>\n",
       "      <td>0.782698</td>\n",
       "      <td>0.348962</td>\n",
       "      <td>0.104962</td>\n",
       "      <td>0.5</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>21.6</td>\n",
       "      <td>3.117950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.000236</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.242302</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.172840</td>\n",
       "      <td>0.694386</td>\n",
       "      <td>0.599382</td>\n",
       "      <td>0.348962</td>\n",
       "      <td>0.104962</td>\n",
       "      <td>0.5</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>34.7</td>\n",
       "      <td>3.575151</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.000293</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.063050</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.150206</td>\n",
       "      <td>0.658555</td>\n",
       "      <td>0.441813</td>\n",
       "      <td>0.448545</td>\n",
       "      <td>0.066794</td>\n",
       "      <td>0.6</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>33.4</td>\n",
       "      <td>3.538057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000705</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.063050</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.150206</td>\n",
       "      <td>0.687105</td>\n",
       "      <td>0.528321</td>\n",
       "      <td>0.448545</td>\n",
       "      <td>0.066794</td>\n",
       "      <td>0.6</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>36.2</td>\n",
       "      <td>3.616309</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       CRIM    ZN     INDUS  CHAS       NOX        RM       AGE       DIS  \\\n",
       "0  0.000000  0.18  0.067815   0.0  0.314815  0.577505  0.641607  0.269203   \n",
       "1  0.000236  0.00  0.242302   0.0  0.172840  0.547998  0.782698  0.348962   \n",
       "2  0.000236  0.00  0.242302   0.0  0.172840  0.694386  0.599382  0.348962   \n",
       "3  0.000293  0.00  0.063050   0.0  0.150206  0.658555  0.441813  0.448545   \n",
       "4  0.000705  0.00  0.063050   0.0  0.150206  0.687105  0.528321  0.448545   \n",
       "\n",
       "        TAX  PTRATIO  ...  RAD_2  RAD_3  RAD_4  RAD_5  RAD_6  RAD_7  RAD_8  \\\n",
       "0  0.208015      0.3  ...      0      0      0      0      0      0      0   \n",
       "1  0.104962      0.5  ...      1      0      0      0      0      0      0   \n",
       "2  0.104962      0.5  ...      1      0      0      0      0      0      0   \n",
       "3  0.066794      0.6  ...      0      1      0      0      0      0      0   \n",
       "4  0.066794      0.6  ...      0      1      0      0      0      0      0   \n",
       "\n",
       "   RAD_24  MEDV  log_MEDV  \n",
       "0       0  24.0  3.218876  \n",
       "1       0  21.6  3.117950  \n",
       "2       0  34.7  3.575151  \n",
       "3       0  33.4  3.538057  \n",
       "4       0  36.2  3.616309  \n",
       "\n",
       "[5 rows x 23 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fe_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 506 entries, 0 to 505\n",
      "Data columns (total 23 columns):\n",
      "CRIM        506 non-null float64\n",
      "ZN          506 non-null float64\n",
      "INDUS       506 non-null float64\n",
      "CHAS        506 non-null float64\n",
      "NOX         506 non-null float64\n",
      "RM          506 non-null float64\n",
      "AGE         506 non-null float64\n",
      "DIS         506 non-null float64\n",
      "TAX         506 non-null float64\n",
      "PTRATIO     506 non-null float64\n",
      "B           506 non-null float64\n",
      "LSTAT       506 non-null float64\n",
      "RAD_1       506 non-null uint8\n",
      "RAD_2       506 non-null uint8\n",
      "RAD_3       506 non-null uint8\n",
      "RAD_4       506 non-null uint8\n",
      "RAD_5       506 non-null uint8\n",
      "RAD_6       506 non-null uint8\n",
      "RAD_7       506 non-null uint8\n",
      "RAD_8       506 non-null uint8\n",
      "RAD_24      506 non-null uint8\n",
      "MEDV        506 non-null float64\n",
      "log_MEDV    506 non-null float64\n",
      "dtypes: float64(14), uint8(9)\n",
      "memory usage: 59.9 KB\n"
     ]
    }
   ],
   "source": [
    "fe_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
